/* drawcircles.v
 *
 * Top level entity for the drawcircles circuits.
 * Inputs:
 * - SW[4:0] - a value for Y coordinate of the center of the circle (times 4 + 56). Should be between 0 and 31.
 * - SW[10:5] - a value for X coordinate of the center of the circle (times 4 + 32). Should be between 0 and 63.
 * - SW[13:11] - the colour of the circle to be drawn.
 * - SW[16:14] - the radius of the circle (times 4 + 1).
 * - SW[17] - toggle high to signal that the new circle is now ready.
 * - KEY[0] - asynchronous reset. Press the button to reset the system.
 * Outputs:
 * - circles display on a monitor
 * - LEDG[8] is lit up when new circle can be entered.
 */

module drawpixel_test(
			SW,
			CLOCK_50,
			LEDG,
			KEY,
			VGA_R,
			VGA_G,
			VGA_B,
			VGA_HS,
			VGA_VS,
			VGA_BLANK,
			VGA_SYNC,
			VGA_CLK);
	input [17:0] SW;
	input [3:0] KEY;
	input CLOCK_50;
	output [8:0] LEDG;
	output [9:0] VGA_R;
	output [9:0] VGA_G;
	output [9:0] VGA_B;
	output	VGA_HS,
			VGA_VS,
			VGA_BLANK,
			VGA_SYNC,
			VGA_CLK;		

	/* Local wires to connect modules together */
	wire circle_done, circle_go, ready;
	wire [2:0] colour;
	wire resetN, go;
	wire [8:0] to_VGA_x;
	wire [7:0] to_VGA_y;
	wire to_VGA_plot;
	wire [8:0] new_CX;
	wire [7:0] new_CY;
	wire [2:0] new_colour;
	wire [4:0] new_radius;
	wire       to_VGA_plot_edge;
	
	assign new_CX = 9'h20 + {1'b0, SW[10:5], SW[10:9]};
	assign new_CY = 9'h38 + {1'b0, SW[4:0], SW[4:3]};
	assign new_colour = SW[13:11];
	assign new_radius = {SW[16:14], 2'h1};
	assign go = SW[17];
	assign resetN = KEY[0];
	
	//temp assignments
	assign to_VGA_plot = go;
	assign to_VGA_x = new_CX;
	assign to_VGA_y = new_CY;
	assign colour   = new_colour;
	
	//posedge_Detector(CLOCK_50, to_VGA_plot, to_VGA_plot_edge);	
	
	vga_adapter VGA(
				.resetn(resetN),
				.clock(CLOCK_50),
				.colour(colour),
				.x(to_VGA_x),
				.y(to_VGA_y),
				.plot(to_VGA_plot_edge),
				.VGA_R(VGA_R),
				.VGA_G(VGA_G),
				.VGA_B(VGA_B),
				.VGA_HS(VGA_HS),
				.VGA_VS(VGA_VS),
				.VGA_BLANK(VGA_BLANK),
				.VGA_SYNC(VGA_SYNC),
				.VGA_CLK(VGA_CLK));
			defparam VGA.RESOLUTION = "320x240";
			defparam VGA.MONOCHROME = "FALSE";
			defparam VGA.BITS_PER_COLOUR_CHANNEL = 1;
			defparam VGA.BACKGROUND_IMAGE = "background.mif";


	/* Circle algorithm FSM */
	
	/* User interface */	
	
	/* Circuit outputs. */

endmodule
		
